1. Field
Embodiments of the invention relate to the field of queues used to store messages; more specifically, to handling congestion in queues used to store messages.
2. Background Information
It is common to store messages that are sent from a message sender to a message receiver in a queue. The newer messages sent by the message sender may be stored or enqueued in the queue, and older messages may be dequeued and provided to the message receiver. The queue may represent a linear or First-In-First-Out (FIFO) structure in which the messages in the queue are kept generally in order. In a FIFO queue, when a given message is added to the queue, all messages previously added to the queue before the given message are removed from the queue before the given message is removed from the queue, whereas all messages added to the queue after the given message are removed from the queue after the given message is removed from the queue. One advantage of such a queue is that it may help to implement an asynchronous communication interface between the message sender and the message receiver. The message receiver does not need to receive or process messages when they are sent by the message sender. Rather, the queue may store the messages sent until the messages are dequeued by the message receiver (e.g., when the message receiver is ready to handle them).
Congestion may tend to occur when more messages are added to the queue than are removed from the queue over a given period of time. The congestion may occur for various reasons, such as, for example, the message sender sending a flood of messages, or the message receiver failing to dequeue messages at an appropriate rate. One way to handle such congestion is to drop or discard the new messages received by the queue from the message sender, which are to be stored in the queue.